 package math;

import org.junit.Test;

//汉明距离
public class Ex461 {
    class Solution {
        public int hammingDistance(int x, int y) {
            int count = 0, t = 1;
            for (int i = 0; i < 32; i++) {
                if (((x & t) ^ (y & t)) != 0) count++;
                t <<= 1;
            }
            return count;
        }
    }

    @Test
    public void test() {
        Solution s = new Solution();
        int res = s.hammingDistance(Integer.MIN_VALUE - 1, 0);
        // System.out.println(res);
        System.out.println(Integer.toString(Integer.MIN_VALUE, 32));
        System.out.println(Integer.toString(-900, 2));
        System.out.println(Integer.toBinaryString(Integer.MIN_VALUE));

    }
}
